import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   
   {
    title: '规则名',
    align:"center",
    dataIndex: 'ruleName',
    width:150
   },
   {
    title: '调度类型',
    align:"center",
     width:150,
    dataIndex: 'ruleType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'rule_type');
    },
   },
   {
    title: '授权人数',
    align:"center",
    width:150,
    dataIndex: 'personCount',
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
     width:80,
    customRender: ({ text }) => {
      return !text?"":(text=='0'?'停用':'在用');
    },
   },
   {
    title: '设置状态',
    align:"center",
    slots: { customRender: 'optionCel' },
    width:150
   },
   {
    title: '创建日期',
    align:"center",
    sorter: true,
     width:150,
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    dataIndex: 'updateTime',
    width:150
   },
  
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
      label: "规则名",
      field: 'ruleName',
      component: 'JInput',
      //colProps: {span: 6},
  },
  {
      label: "调度类型",
      field: 'ruleType',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:"rule_type",
      }
      
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '规则名',
    field: 'ruleName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入规则名!'},
      ];
 },
  },
  {
    label: '调度类型',
    field: 'ruleType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"rule_type"
     },
     dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择调度类型!'},
      ];
 },
  },
  {
    label: '状态',
    field: 'status',
    component: 'RadioButtonGroup',
    // component: 'JSelectInput',
    defaultValue: '1',
    componentProps: {
      options: [
        { label: '在用', value: '1' },
        { label: '停用', value: '0' }
      ],
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择状态!'},
      ];
 },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

 
/** 规则关联设备列表
 */
export const ruleDevColumns: BasicColumn[] = [
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'devName',
   width:150
  },
  {
   title: '设备类型',
   align:"center",
    width:150,
   dataIndex: 'devType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '在线状态',
   align:"center",
   dataIndex: 'isOnline',
    width:80,
   customRender: ({ text }) => {
     return !text?"":(text=='0'?'离线':'在线');
   }
   }
];

//规则关联设备查询数据
export const ruleDevSearchFormSchema: FormSchema[] = [
  {
      label: "设备名称",
      field: 'devName',
      width:150,
      component: 'Input',
      //colProps: {span: 6},
  }
];

export const devColumns:BasicColumn[] = [
  {
   title: '设备编码',
   align:"center",
   dataIndex: 'deviceCode'
  },
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName'
  },
  {
   title: '设备标识码',
   align:"center",
   dataIndex: 'deviceSn'
  },
  {
   title: '设备类型',
   align:"center",
   dataIndex: 'deviceType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'deviceType');
   },
  },
  {
   title: '设备地址',
   align:"center",
   dataIndex: 'deviceIp'
  },
];
export const searchDevFormSchema:FormSchema[] = [
  {
      label: "设备名称",
      field: 'deviceName',
      width:150,
      component: 'Input',
      //colProps: {span: 6},
  }
];
// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '创建日期',order: 0,view: 'datetime', type: 'string'},
  updateTime: {title: '更新日期',order: 1,view: 'datetime', type: 'string'},
  ruleName: {title: '规则名',order: 2,view: 'text', type: 'string'},
  ruleType: {title: '调度类型',order: 3,view: 'list', type: 'string'},
  status: {title: '状态',order: 4,view: 'list', type: 'string'}
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

//列表数据
export const channelColumns: BasicColumn[] = [
  {
   title: '名称',
   align:"center",
   dataIndex: 'name'
  },
 //  {
 //   title: '通道类型',
 //   align:"center",
 //   dataIndex: 'channelType',
 //   customRender: ({ text }) => {
 //     return render.renderDict(text, 'channel_type');
 //   },
 //  },
  {
   title: '出入类型',
   align:"center",
   dataIndex: 'accessType',
   customRender: ({ text }) => {
     return render.renderDict(text, 'accessType');
   },
  },
  {
   title: '描述',
   align:"center",
   dataIndex: 'memo'
  },
];
//查询数据
export const channelSearchFormSchema: FormSchema[] = [
 {
     label: "名称",
     field: 'name',
     component: 'Input',
     //colProps: {span: 6},
  },
 {
     label: "出入类型",
     field: 'accessType',
     component: 'JDictSelectTag',
     componentProps:{
       dictCode:"accessType",
       stringToNumber: true,
     }
     
  },
];